package com.example.elysiumease.result;

public class ResponseResult<T> {
    private int code;
    private String message;
    private T data;
    private long timestamp;

    // 私有构造函数
    private ResponseResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.timestamp = System.currentTimeMillis();
    }

    // 成功响应（带数据）
    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<>(200, "Success", data);
    }

    // 成功响应（无数据）
    public static ResponseResult<Void> success() {
        return new ResponseResult<>(200, "Success", null);
    }

    // 通用失败响应
    public static <T> ResponseResult<T> fail(int code, String message) {
        return new ResponseResult<>(code, message, null);
    }

    // 参数校验失败
    public static ResponseResult<Void> validateFailed(String message) {
        return new ResponseResult<>(400, message, null);
    }

    // Getters
    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public T getData() {
        return data;
    }

    public long getTimestamp() {
        return timestamp;
    }
}